struct Container(i32, i32);

trait Containers {
    type A;
    type B;
    fn containers(&self, _: &Self::A, _: &Self::B) -> bool;
    fn first(&self) -> i32;
    fn last(&self) -> i32;
}

impl Containers for Container {
    type A = i32;
    type B = i32;
    fn containers(&self, a: &i32, b: &i32) -> bool {
        self.0 == *a && self.1 == *b
    }

    fn first(&self) -> i32 {
        self.0
    }

    fn last(&self) -> i32 {
        self.1
    }
}

// 虽然只要C，但是也要声明A和B，否则会报错
fn difference<C: Containers>(container: &C) -> i32
{
    container.last() - container.first()
}

fn main() {
    let number_1 = 3;
    let number_2 = 10;

    let container = Container(number_1, number_2);

    println!("Does the container contain {} and {}? {}", &number_1, &number_2, container.containers(&number_1, &number_2));

    println!("The first number is {} and the last number is {}. The difference is {}", container.first(), container.last(), difference(&container));

    println!("The difference is {}", difference(&container)); // This line will cause a compile error because the function is not defined for the type Container.
}